# coding=utf-8
# 全世界最帅的帅哥
from flask import g

from ysgg1_club_comment.utils.base_serializers import BaseSerializer
from ysgg1_club_comment.utils.handle_dict import handle_dict
from ysgg1_club_subject.subject_views.liked_views import is_liked, get_liked_count


class RadioTypeSerializer(BaseSerializer):
    def to_dict(self):
        subject_info, option_list, label_name_list = self.data[0], self.data[1], self.data[2]

        data = {
            "id": subject_info.id,
            "subject_name": subject_info.subject_name,
            "subject_difficult": subject_info.subject_difficult,
            "subject_type": subject_info.subject_type,
            "settle_name": subject_info.settle_name,
            "subject_score": subject_info.subject_score,
            "subject_parse": subject_info.subject_parse,
            "option_list": option_list,
            "label_name": label_name_list,
            "liked": is_liked(str(subject_info.id), g.token),
            "count": get_liked_count(str(subject_info.id))
        }

        return handle_dict(data)

